package com.example.yk_lx.friend;

import androidx.lifecycle.MutableLiveData;

import com.example.yk_lx.baseMVVM.BaseRepo;
import com.hyphenate.EMValueCallBack;
import com.hyphenate.chat.EMGroup;

import java.util.List;

public class FriendRepo extends BaseRepo {
    public void getFriend(MutableLiveData<List<String>> success,MutableLiveData<String> fail){
        client.contactManager().aysncGetAllContactsFromServer(new EMValueCallBack<List<String>>() {
            @Override
            public void onSuccess(List<String> value) {
                success.postValue(value);
            }

            @Override
            public void onError(int error, String errorMsg) {
                fail.postValue(errorMsg);
            }
        });
    }

    public void getGroup(MutableLiveData<List<EMGroup>> success,MutableLiveData<String> fail){
        List<EMGroup> groups = client.groupManager().getAllGroups();
        if(groups.isEmpty()){
            fail.postValue("没有获取到相关数据");
            return;
        }
        success.postValue(groups);
    }
}
